package com.qidianit.mes.production.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qidianit.mes.common.pojo.MesResult;
import com.qidianit.mes.pojo.ProcessStep;
import com.qidianit.mes.production.service.ProcessStepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 戴着假发的程序员
 * @company 起点编程
 * @date 2025/8/4 10:39
 * @description
 */
@RestController
@RequestMapping("/processStep")
public class ProcessStepController {
    @Autowired
    private ProcessStepService processStepService;

    @DeleteMapping("/deletes")
    public MesResult<Integer> deleteBatch( String[] stepIds) {
        return processStepService.deleteBatch(stepIds);
    }
    @DeleteMapping("/{stepId}")
    public MesResult<Integer> deleteById(@PathVariable Integer stepId) {
        return processStepService.deleteById(stepId);
    }

    @PutMapping
    public MesResult<Integer> updateProcessStepById(@RequestBody ProcessStep processStep) {
        return processStepService.updateProcessStepById(processStep);
    }

    @GetMapping("/{stepId}")
    public MesResult<ProcessStep> getProcessStepById(@PathVariable Integer stepId) {
        return processStepService.getProcessStepById(stepId);
    }

    @GetMapping("/list")
    public MesResult<Page<ProcessStep>> listProcessStep(String processCode,@RequestParam(defaultValue = "1")int pageNum, @RequestParam(defaultValue = "10") int pageSize) {
        return processStepService.listProcessStep(processCode,pageNum,pageSize);
    }

    @PostMapping
    public MesResult<ProcessStep> saveStep(@RequestBody ProcessStep processStep) {
        return processStepService.saveStep(processStep);
    }
}
